#include"ShellSort.h"

void Swap(data* x1, data* x2)
{
	data* mid = (*x1);
	*x1 = *x2;
	*x2 = mid;
}

void ShellSort(data* arr, int r)
{
	assert(arr);
	int garp = r;
	while (garp > 1)
	{
		garp = garp / 3 + 1;
		for (int i = 0; i < r - garp; i++)
		{
			int end = i;
			data mid = arr[end+garp];
			while (end >= 0)
			{
				if (arr[end] > mid)
				{
					arr[end+garp] = arr[end];
					end-=garp;
				}
				else break;
			}
			arr[end+garp] = mid;
		}
	}
}